package com.matt.repository.impl;

import com.matt.foundation.vo.ChannelVo;
import com.matt.repository.base.BaseNativeSqlRepository;
import com.matt.repository.base.BudgetTempleteNativeRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/10/26
 * *******************************
 */
@Service
public class BudgetTempleteNativeRepositoryImpl extends BaseNativeSqlRepository implements BudgetTempleteNativeRepository {


    @Override
    public List<ChannelVo> findAll(String areaId) {
        String querySql = String.format("select id as id ,name as name,type as type,typeVal as typeVal from budget_templete where  ((parentId=1 and areaId is null) or ( parentId=1 and year(created)=year(now()) and month(created)=month(now()) and areaId='%s')) order by sort desc",areaId);
        List<ChannelVo> list = sqlObjectList(querySql,ChannelVo.class);
        return list;
    }
}
